{# Copyright 2014-2017 Siemens AG

   Copying and distribution of this file, with or without modification,
   are permitted in any medium without royalty provided the copyright notice and this notice are preserved.
   This file is offered as-is, without any warranty.
#}
{% import "include/macros.html.twig" as macro %}

<form method="post" id="uiClearingForm">
  <input name="lastItem" id="lastItem" type="hidden" value="{{ itemId }}"/>
  <input name="upload" id="upload" type="hidden" value="{{ uploadId }}"/>
  <table>
    <tr>
      <td style="vertical-align:top;">
        <button type="submit" name="update" class="btn btn-default btn-sm" id="prev" disabled>&lt;</button>
        <button type="submit" name="update" class="btn btn-default btn-sm" onclick="form.action = '{{ uri }}&item={{ itemId }}';">{{ 'Submit'|trans }}</button>
        <button type="submit" name="update" class="btn btn-default btn-sm" id="next" disabled>&gt;</button>
      </td>
      <td>
        <input type="radio" class="info-bullet view-license-rc-size" name="FileSelection" value="none"> 
        {% trans "Go through all files" %}
        <img data-toggle="tooltip" data-placement="left" src="images/info_16.png" title="{{ 'Back and forward browsing through every file of the upload'|trans }}" alt="" class="info-bullet"/></img>
        <br/>
        <input type="radio" class="info-bullet view-license-rc-size" name="FileSelection" value="noLicense">
        {% trans "Go through all files with licenses" %}
        <img data-toggle="tooltip" data-placement="left" src="images/info_16.png" title="{{ 'Back and forward browsing going through files only with a license found by a scanner agent, regardless of an existing clearing result or not'|trans }}" alt="" class="info-bullet"/></img>
        <br/>
        <input type="radio" class="info-bullet view-license-rc-size" name="FileSelection" value="alreadyCleared">
        {% trans "Go through all files with licenses and no clearing result" %}
        <img data-toggle="tooltip" data-placement="left" src="images/info_16.png" title="{{ 'Back and forward browsing going through files only with a license found by a scanner agent only where no clearing result was created. This setting is useful for just browsing to “remaining work”'|trans }}" alt="" class="info-bullet"/>
      </td>
    </tr>
  </table>

  <div class="groupBox">
    <fieldset class="border p-2" style="display:inline">
      <legend style="width:auto;">
        {{ 'Clearing decision scope'| trans }}
      </legend>
      <input type="checkbox" class="info-bullet view-license-rc-size" name="globalDecision" id="globalDecision"  onclick="checkIfEligibleForGlobalDecision()" {% if selectedClearingScope==1 %}checked{% endif %}/>
      {{ 'Apply decision to all future occurrences of this file'|trans }}
      <img data-toggle="tooltip" data-placement="left" src="images/info_16.png" title="{{ 'Based on a hash computation of the file contents, Fossology will determine a future occurrence of the same file. Then, if  the same file is part of a subsequent upload, this clearing decision will apply there as well.  Consider that this decision will impact also upload of other users. It should be checked with much care'|trans }}" alt="" class="info-bullet"/ >
    </fieldset>
    <br/>
    <br/>
    <fieldset class="border p-2" style="display: inline;" {% if tmpClearingType %}class="border-danger"{% endif %} id="decTypeSet">
      <legend style="width:auto;">
        {{ 'Clearing decision type'| trans }}
      </legend>
      <input type="radio" class="info-bullet view-license-rc-size" name="clearingTypes" value="2" />
      {{ 'No license known'| trans }}
      <img src="images/info_16.png" data-toggle="tooltip" title="{{ 'Even after review, no license relevant information can be determined'|trans }}" alt="" class="info-bullet"/></img>
      {% for typeKey,typeText in clearingTypes %}
        <br/>
        <input type="radio" class="info-bullet view-license-rc-size" name="clearingTypes" value="{{ typeKey }}"
        {% if typeKey==selectedClearingType %}checked="checked"{% endif %}/> {{ typeText }}<img src="images/info_16.png" data-toggle="tooltip" {% if typeKey==3 %} title="{{ 'Mark the file for having had a look at it, but a clearing result cannot be determined at the current time'|trans }}" {% elseif typeKey==4 %} title="{{ 'There is license relevant information, but this is not relevant information for the clearing of this file (for example, files that are not used at all and also not distributed)'|trans }}" {% else %} title="{{ 'This setting  considers the selection of licenses  shown in the table below to create a clearing result'|trans }}" {% endif %} alt="" class="info-bullet"/>
      {% endfor %}
    </fieldset>
  </div>
</form>

<div class="groupBox">
  {{ macro.table("licenseDecisionsTable", licenseDecisionsHeaders) }}
</div>

<div class="groupBox">

  {% if auditDenied %}
    {{ 'Sorry, you do not have write (or above) permission on this upload, thus you cannot change the license of this
    file.
    '| trans }}
  {% else %}
    <button type="button" data-toggle="modal" data-target="#userModal" class="btn btn-default btn-sm" onclick="openUserModal();">
      {{ 'User Decision ...'| trans }}
    </button><img src="images/info_16.png" data-toggle="tooltip" title="{{ 'Add manually a license that is not found by scanners or bulk'|trans }}" alt="" class="info-bullet"/>
    &nbsp;
    <button type="button" data-toggle="modal" data-target="#bulkModal" class="btn btn-default btn-sm" onclick="openBulkModal();">
      {{ 'Bulk Recognition ...'| trans }}
    </button><img src="images/info_16.png" data-toggle="tooltip" title="{{ 'Adding or removing a license based on a text fragment that is searched for across the relevant files'|trans }}" alt="" class="info-bullet"/>
    &nbsp;
    <button type="button" data-toggle="modal" data-target="#ClearingHistoryDataModal" class="btn btn-default btn-sm" onclick="openClearingHistoryDataModal();">
      {{ 'Clearing History ...'| trans }}
    </button><img src="images/info_16.png" data-toggle="tooltip" title="{{ 'View the clearing history for this file: The table will show which user added or removed license results for this particular file in order to create a clearing decision. Clearing decisions are created when the user clicks on the button "Submit" or on the go next and go previous buttons'|trans }}" alt="" class="info-bullet"/>
    &nbsp;
    <br/>
    <span id="bulkIdResult" name="bulkIdResult"></span>
    <div style="padding-top: 10px;">
    <!-- The user Modal -->
    <div class="modal" id="userModal" tabindex="-1" role="dialog" aria-labelledby="userModalLabel" aria-hidden="true" data-backdrop="false">
      <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
          <!-- Modal Header -->
          <div class="modal-header">
            <h4 class="modal-title">Add a New License</h4>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span>
            </button>
          </div>
          <!-- Modal body -->
          <div class="modal-body" style="max-height:300px;overflow:auto;">
            <div style="padding-bottom: 10px">
              {{ macro.table("licenseSelectionTable") }}
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- The clearing history Modal -->
    <div class="modal" id="ClearingHistoryDataModal" tabindex="-1" role="dialog" aria-labelledby="ClearingHistoryDataModalLabel" aria-hidden="true" data-backdrop="false">
      <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
          <!-- Modal Header -->
          <div class="modal-header">
            <h4 class="modal-title">Clearing History</h4>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span>
            </button>
          </div>
          <!-- Modal body -->
          <div class="modal-body">
            <div style="padding-bottom: 10px;">
              {{ macro.table("ClearingHistoryDataModalTable") }}
            </div>
          </div>
        </div>
      </div>
    </div>

      {% include 'ui-clearing-view_bulk.html.twig' %}
    </div>
  {% endif %}

</div>
<div class="groupBox" id="bulkHistory" {% if not bulkHistory %}hidden{% endif %}>

<h3>
{{ 'Bulk History'| trans }}
</h3>

<div class="scrollable2">
{% include 'bulk-history.html.twig' %}
</div>
</div>
